import request from '@/utils/request'

const getArticleDetaiAPI = ({
  id
}) => {
  return request({
    method: 'get',
    url: `/v1_0/articles/${id}`
  })
}
const followAutAPI = ({
  autId
}) => {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target: autId
    }
  })
}
// 文章详情页 - 取消关注作者
const unfollowAutAPI = ({
  autId
}) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/user/followings/${autId}`
  })
}
// 文章 - 点赞
const articleLikeAPI = ({
  target
}) => {
  return request({
    url: '/v1_0/article/likings',
    method: 'POST',
    data: {
      target: target
    }
  })
}

// 文章 - 取消点赞
const articleDisLikeAPI = ({
  artId
}) => {
  return request({
    url: `/v1_0/article/likings/${artId}`,
    method: 'DELETE'
  })
}

const getcommentlistAPI = ({
  artId,
  offset,
  limit = 10
}) => {
  return request({
    method: 'get',
    url: '/v1_0/comments',
    params: {
      type: 'a',
      source: artId,
      offset,
      limit
    }
  })
}
const commentLikingAPI = ({
  comId
}) => {
  return request({
    url: '/v1_0/comment/likings',
    method: 'POST',
    data: {
      target: comId
    }
  })
}
const commentDisLikingAPI = ({
  comId
}) => {
  return request({
    url: `/v1_0/comment/likings/${comId}`,
    method: 'DELETE'
  })
}
export {
  commentDisLikingAPI, commentLikingAPI, getcommentlistAPI, getArticleDetaiAPI, followAutAPI, unfollowAutAPI, articleLikeAPI, articleDisLikeAPI
}
